<?php

$server = new Swoole\WebSocket\Server('0.0.0.0', 9502);

$server->on('Open',function ($server, $request) {
    $server->push($request->fd, 'welcome \n');
});

$server->on('Message', function($server, $frame){
    var_dump($frame->data);

    $server->push($frame->fd, 'data:'.$frame->data);
});

$server->on('Close', function ($server, $fd)  {
    echo 'server:'.$fd.'closed\n';
});

$server->start();